﻿using DM_Sqlite.MappingClass;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DM_TOOLS.Tools.DBC.DBCUser
{
    public static class EchartHelper
    {
        /// <summary>
        /// 从 dm_props_user 实例中提取所有 echartXchan 的通道列表，包括经纬度和速度
        /// </summary>
        /// <param name="user">dm_props_user 实例</param>
        /// <returns>通道名称列表</returns>
        public static List<string> GetAllEchartChannels(dm_dbcprops_user user)
        {
            if (user == null)
                throw new ArgumentNullException(nameof(user));

            var chans = new[]
            {
            user.echart1chan,
            user.echart2chan,
            user.echart3chan,
            user.echart4chan,
            user.echart5chan,
            user.echart6chan
            };

            var list=chans
                .Where(c => !string.IsNullOrWhiteSpace(c))
                .SelectMany(c => c.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
                .Distinct()
                .ToList();
            // ✅ 添加 lat 和 lon 两个通道
            list.Add("lat");
            list.Add("lon");
            list.Add("spd");
            // 去重（以防已有）
            return list.Distinct().ToList();
        }
    }
}
